Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only create links for trusted href values #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nhnb
Copy link

@nhnb nhnb commented May 22, 2024

At the moment, a url value of javascript:alert(document.domain) is converted to
<a href="javascript:alert(document.domain)">javascript:alert(document.domain)</a>.

I belief the risk is very low because the javascript code is clearly visible. But it might be a good idea to fix this issue anyway.

Steps to reproduce:

    public static void main(String[] args) throws IOException {
        CSLItemData item = new CSLItemDataBuilder()
            .type(CSLType.ARTICLE_JOURNAL)
            .title("Protein measurement with the Folin phenol reagent")
            .author(
                new CSLNameBuilder().given("G").family("Krüger").build()
            )
            .URL("javascript:alert(document.domain)")
            .build();

        ItemDataProvider provider = new ListItemDataProvider(item);
        CSL csl = new CSL(provider, "ieee-with-url");
        csl.registerCitationItems(item.getId());
        csl.setConvertLinks(true);
        csl.setOutputFormat("html");

        String res = csl.makeBibliography().makeString();
        System.out.println(res);
    }

@michel-kraemer
Copy link
Owner

Nice catch! Thank you. I'll merge the PR together with your other one (#243).

Copy link

github-actions bot commented Aug 5, 2024

This pull request has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in two weeks if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants